#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <algorithm>
#include <unordered_map>
using namespace std;

class Solution {
public:
    int evalRPN(vector<string>& tokens) {
        stack<int> st;
        unordered_map<string, int> hash;
        hash["+"]++, hash["-"]++, hash["*"]++, hash["/"]++;
        for (auto& str : tokens)
        {
            if (hash.count(str))
            {
                int right = st.top(); st.pop();
                int left = st.top(); st.pop();

                switch (str[0])
                {
                case '+':
                    st.push(right + left);
                    break;
                case '-':
                    st.push(left - right);
                    break;
                case '*':
                    st.push(right * left);
                    break;
                case '/':
                    st.push(left / right);
                    break;
                }
            }
            else
                st.push(stoi(str));
        }
        return st.top();
    }
};

int main()
{
	vector<string> str = { "10","6","9","3","+","-11","*","/","*","17","+","5","+" };
    Solution().evalRPN(str);
	return 0;
}